package com.example.springboot.demo.controller;

import jakarta.annotation.Resource;
import me.ahoo.cosid.IdGenerator;
import me.ahoo.cosid.cosid.CosIdGenerator;
import me.ahoo.cosid.cosid.CosIdState;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cosid")
public class CosIdController {

    @Resource
    private IdGenerator idGenerator;

    @Resource
    private CosIdGenerator cosIdGenerator;

    @GetMapping("/id1")
    @ResponseBody
    public Object id1() {
        String id = idGenerator.generateAsString();
        return id;
    }

    @GetMapping("/sax")
    public CosIdState asState(String id) {
        return cosIdGenerator.getStateParser().asState(id);
    }

}
